package com.cheng.controller;

import com.cheng.common.results.DataRslt;
import com.cheng.data.vo.NoticeVO;
import com.cheng.operation.BorrowOperation;
import com.cheng.operation.CompanyMoveInfOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: ChengJW
 * @date: 2021/11/7 20:21
 * @version: 1.0
 * @description: home 页面处理器
 */
@Controller
public class HomeController extends BaseController{

    private final static Logger log = LoggerFactory.getLogger(HomeController.class);

    @Autowired
    private BorrowOperation borrowOperation;

    @Autowired
    private CompanyMoveInfOperation companyMoveInfOperation;

    @RequestMapping("/userinfo/home")
    public String home(){
        return "home";
    }

    /**
    * @author: ChengJW
    * @params: []
    * @return: com.cheng.common.results.DataRslt
    * @date: 2021/12/21
    * @description: home 待归还档案提醒信息
    */
    @RequestMapping("/home/queryOverDateOfBrowInfo")
    @ResponseBody
    public DataRslt queryOverDateOfBrowInfo(){
        NoticeVO noticeVO = borrowOperation.queryBorrowInfoNoticeVO(getUrNm());
        if (noticeVO != null){
            return success(noticeVO);
        }
        return failure();
    }

    /**
     * @author: ChengJW
     * @params: []
     * @return: com.cheng.common.results.DataRslt
     * @date: 2021/12/21
     * @description: home 待迁入档案提醒信息
     */
    @RequestMapping("/home/queryOverDateOfMoveInfo")
    @ResponseBody
    public DataRslt queryOverDateOfMoveInfo(){
        NoticeVO noticeVO = companyMoveInfOperation.queryMoveNoticeVO(getUrCode());
        if (noticeVO != null){
            return success(noticeVO);
        }
        return failure();
    }
}
